﻿$(function () {
    $('.loginbox').css({ 'position': 'absolute', 'left': ($(window).width() - 692) / 2 });
    $(window).resize(function () {
        $('.loginbox').css({ 'position': 'absolute', 'left': ($(window).width() - 692) / 2 });
    })
    $("#log").click(function () {
        var userName = $("#userName").val();
        var password = $("#password").val();
        var url = "";
        if (userName === "") {
            layer.tips('请输入用户名！', '#userName', {
                tips: [1, '#fe9913'] //还可配置颜色
            });
            return false;
        }
        if (password === "") {
            layer.tips('请输入密码！', '#password', {
                tips: [1, '#fe9913'] //还可配置颜色
            });
            alert("请输入密码");
            return false;
        }
        //登录前访问地址
        var urlParam = getUrlParam("ReturnUrl");
        //if (urlParam != null) {
        //    url = "Login/LoginAsync";
        //}
        //else
        //{
        //    url = "Login/LoginAsync";
        //}
        url = "Login/LoginAsync";
        $.post(url, {
            Name: userName,
            password: password,
            ReturnUrl: urlParam
        }, function (data) {

            if (data.resultSign ===2) {
                layer.tips('请输入正确的用户名或密码！','#log', {
                    tips: [1, '#fe9913'] //还可配置颜色
                });
            }
            else {
                if (urlParam != null) {
                    window.location.href = "" + urlParam + "";
                }
                else {
                    window.location.href = "../Home/Main";
                }
            }
        }, "json");
    });
});